package com.oop.Demo08;

public class test {
    public static void main(String[] args) {
        int a = 1;
        int b = 0;

        try {//try监控区域
            System.out.println(a/b);
        }catch (Error error){//catch(想要捕获的异常类型[Throwable\Error\Exception]) 捕获异常,catch可以写多层(小->大)
            System.out.println("error:"+error);
        }catch (Exception e) {
            System.out.println("Exception:" + e);
        }catch(Throwable t){
            System.out.println("Throwable"+t);
        }
        finally {//程序无论是否出现异常,都将执行finally代码块,处理善后事宜
            System.out.println("finally");
        }
        System.out.println("www");
        //finally 非必须,但IO流或涉及资源,无论如何都要释放,则放在fianlly

    }
}

    